package edu.zac.aop;

import edu.zac.pojo.Emp;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Title
 * @Author Peihan.Zhang
 * @Email zhangpeihan@sjgtw.com
 * @Date 2021/10/23 9:58
 * @Versions 1.0
 */
@Component
@Aspect
public class SpringAop {
       private  static Map<Integer,Object> map;

    @Around("execution(* edu.zac..*.*.*(..))")
    public Object around(ProceedingJoinPoint joinPoint){
           Object result =null;

            Emp emp = (Emp) joinPoint.getArgs()[0];
            if (map.containsKey(emp.getId())){

                return  map.get(emp.getId());

            }else{

//                result = joinPoint.proceed();
                map.put(emp.getId(), emp);

            }

            return  result;


    }
}
